/*
 * SiFiSy - A File System Simulator
 * Copyright (C) 2010  SevenSoft
 *
 * This file is part of SiFiSy.
 *
 * SiFiSy is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * SiFiSy is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with SiFiSy.  If not, see <http://www.gnu.org/licenses/>.
 */

package sifisy.newgui;

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.border.TitledBorder;

/**
 * @author Giuseppe Biolo
 * @version %I%, %G%
 * @createData 17/05/2010
 */
public class FileManager extends JPanel {
    private Checkbox fmAddSingleFile;
    private Checkbox fmAddMoreFiles;
    private JLabel fmFileDimension_l;
    private JTextField fmFileDimension_t;
    private JComboBox fmFileDimension_c;
    private JLabel fmFileContiguousBlocks_l;
    private JTextField fmFileContiguousBlocks_t;

    private void initComponents() {
        fmAddSingleFile = new Checkbox("Frammentazione", null, true);
        fmAddMoreFiles = new Checkbox("Gestione Manuale", false);
        fmFileDimension_l = new JLabel("Dimensione:");
        fmFileDimension_t = new JTextField(5);
        fmFileDimension_c = new JComboBox();
        fmFileDimension_c.addItem("Byte");
        fmFileDimension_c.addItem("KB");
        fmFileDimension_c.addItem("MB");
        fmFileDimension_c.addItem("GB");
        fmFileDimension_c.addItem("TB");
        fmFileContiguousBlocks_l = new JLabel("Numero blocchi contigui:");
        fmFileContiguousBlocks_t = new JTextField(5);
    }

    public FileManager(String type) {
        if (type.equals("single")) {
            JPanel fileDimensionLabel = new JPanel(new FlowLayout(FlowLayout.LEFT));
            fileDimensionLabel.add(fmFileDimension_l);

            JPanel fileDimension = new JPanel(new FlowLayout(FlowLayout.LEFT));
            fileDimension.add(fmFileDimension_t);
            fileDimension.add(fmFileDimension_c);

            JPanel fileContiguousBlocksLabel = new JPanel(new FlowLayout(FlowLayout.LEFT));
            fileContiguousBlocksLabel.add(fmFileContiguousBlocks_l);

            JPanel fileContiguousBlocksText = new JPanel(new FlowLayout(FlowLayout.LEFT));
            fileContiguousBlocksText.add(fmFileContiguousBlocks_t);

            JPanel fileManager = new JPanel(new GridLayout(5, 2));
            fileManager.setBorder(new TitledBorder("Inserimento File"));
            fileManager.add(fmAddSingleFile);
            fileManager.add(fmAddMoreFiles);
            fileManager.add(fileDimensionLabel);
            fileManager.add(fileDimension);
            fileManager.add(fileContiguousBlocksLabel);
            fileManager.add(fileContiguousBlocksText);
        }
    }
}
